package cn.thomas.clock.enums;

import cn.thomas.clock.exception.BusinessException;

public enum ErrorEnum {

    // 基础返回码 --- begin
    SUCCESS(0, "success"),
    FAILED(-1, "服务错误"),
    PARAMS_WRONG(-2, "参数错误或缺失"),
    TOKEN_INVALID(-3, "token 无效"),
    LOGIN_TIME_OUT(-4, "登录超时"),
    USER_SERVICE_ERROR(10001, "调用用户服务接口出错");

    // 错误码
    private int errorCode;

    // 错误信息
    private String message;

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    ErrorEnum(int errorCode, String message) {
        this.errorCode = errorCode;
        this.message = message;
    }

    ErrorEnum(BusinessException e) {
        this.errorCode = e.getErrorCode();
        this.message = e.getMessage();
    }
}